3 # Copyright 2014 Paul Hänsch
5 # This file is part of Busy.
6 # (originally written for and copied from Confetti)
8 # Busy is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Affero General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # Busy is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Affero General Public License for more details.
18 # You should have received a copy of the GNU Affero General Public License
19 # along with Busy. If not, see <http://www.gnu.org/licenses/>.
21 export LC_ALL=C LANG=C
25 # this program is supposed to be symlinked into a http root directory
26 # we will use the http root as object storage (data directory) and call sub
27 # programs from the directory in which the real executable resides
28 # therefore we need to identify the code and data directories _EXEC and _DATA
30 real="$(readlink -f $call)"
31 _EXEC="$(dirname "$real")" #execution directory
32 _DATA="$(dirname "$call")" #storage directory
34 # put debug options in the local.opts file
35 [ -r "$_DATA/local.opts" ] && . "$_DATA/local.opts"
38 debug() { #change to false to disable debugging
39 if [ "$DBG_ENABLED" = true -a -n "$*" ]; then
40 echo -E "$*" >>"$DBG_FILE"
41 elif [ "$DBG_ENABLED" = true -a -z "$*" ]; then
43 elif [ -z "$*" ]; then
50 echo -E "$*" >>/dev/stderr
54 # create directories for object storage
55 [ -w "$_DATA" ] && [ -d "$_DATA" ] || die "storage directory must be writable"
57 for each in "$_DATA"/{Home,Tasks,Wiki,QRcodes}; do
58 [ ! -e "$each" ] && mkdir "$each"
59 [ -w "$each" ] && [ -d "$each" ] || die "storage $each must be a writable directory"
62 # create htaccess file
63 [ -f .htaccess ] || cat >.htaccess <<EOF
65 AddHandler cgi-script .cgi
66 DirectoryIndex index.cgi
68 [ -f .htaccess ] || die "no htaccess file present and unable to create one"
71 . "$_EXEC/constants.sh"
75 if [ -n "$_GET[\"action\"]" ]; then
77 elif [ -n "$_GET[\"export\"]" ]; then